package com.xique.park.controller.web;

import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.controller.client.web.api.IWxAppPlatformApi;
import com.xique.park.controller.client.web.bean.request.ClientOprGateRequest;
import com.xique.park.controller.client.web.service.biz.service.IClientCommandService;
import com.xique.park.controller.client.web.service.service.IWxAppPlatApi;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 视频开闸
 *
 * @author: xique
 */
@RestController
@RequestMapping("/web/video")
public class WebParkVideoController {

    @Autowired
    private IClientCommandService clientCommandService;

    @Autowired
    private IWxAppPlatformApi wxAppPlatformApi;

    @Autowired
    private IWxAppPlatApi iWxAppPlatApi;

    /**
     * 道闸控制（开闸）
     */
    @PostMapping("/openGate")
    @ResponseBody
    @ApiOperation("开闸")
    @PreAuthorize(hasPermi = "park:ipc:openGate")
    @Log(title = "开闸", businessType = BusinessType.COMMAND)
    public AjaxResult openGate(@Validated({ClientOprGateRequest.OpenGate.class}) @RequestBody ClientOprGateRequest request) {
        return clientCommandService.openGate(request);
    }

    /**
     * 道闸控制（关闸）
     */
    @PostMapping("/closeGate")
    @ResponseBody
    @ApiOperation("关闸")
    @PreAuthorize(hasPermi = "park:ipc:closeGate")
    @Log(title = "关闸", businessType = BusinessType.COMMAND)
    public AjaxResult closeGate(@Validated({ClientOprGateRequest.CloseGate.class}) @RequestBody ClientOprGateRequest request) {
        return clientCommandService.closeGate(request);
    }

    /**
     * 获取远程访问相机路径
     */
    @PreAuthorize(hasPermi = "park:ipc:testGate")
    @GetMapping("/getDeviceWebUrl")
    @ResponseBody
    public AjaxResult getDeviceWebUrlAPP(String sn) {
        // return wxAppPlatformApi.getAppDeviceWebUrl(sn);
        return iWxAppPlatApi.getAppDeviceWebUrlSn(sn);
    }
}
